/**
 *    Copyright (c) [2022] [中和农信]
 *    rabbit-mq-plus is licensed under Mulan PSL v2.
 *    You can use this software according to the terms and conditions of the Mulan PSL v2.
 *    You may obtain a copy of Mulan PSL v2 at:
 *             http://license.coscl.org.cn/MulanPSL2
 *    THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 *    See the Mulan PSL v2 for more details.
 *
 */
package com.cfpamf.athean.rabbit.mq.plus.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cfpamf.athean.rabbit.mq.plus.domain.dto.RabbitMqPlusConsumerTaskDTO;
import com.cfpamf.athean.rabbit.mq.plus.domain.po.RabbitMqPlusConsumerTaskPO;
import com.cfpamf.athean.rabbit.mq.plus.repository.RabbitMqPlusConsumerTaskRepository;
import com.cfpamf.athean.rabbit.mq.plus.service.RabbitMqPlusConsumerTaskService;
import com.cfpamf.athena.utils.ObjectUtils;

/**
 * 类RabbitMqPlusConsumerTaskServiceImpl.java的实现描述：
 *
 * @author Andy（陈洪桥）2022年12月12 01:54
 */
@Service
public class RabbitMqPlusConsumerTaskServiceImpl implements RabbitMqPlusConsumerTaskService {

    @Resource
    private RabbitMqPlusConsumerTaskRepository rabbitMqPlusConsumerTaskRepository;

    @Override
    public void save(RabbitMqPlusConsumerTaskPO rabbitMqPlusConsumerTaskPO) {
        rabbitMqPlusConsumerTaskRepository.save(rabbitMqPlusConsumerTaskPO);
    }

    @Override
    public RabbitMqPlusConsumerTaskPO queryOneByQueueNameAndConsumerTypeCode(String queueName,
        String consumerTypeCode) {
        return rabbitMqPlusConsumerTaskRepository.selectOneByQueueNameAndConsumerTypeCode(queueName, consumerTypeCode);
    }

    @Override
    public boolean updateByQueueNameAndConsumerTypeCode(RabbitMqPlusConsumerTaskPO rabbitMqPlusConsumerTaskPO) {
        rabbitMqPlusConsumerTaskRepository.updateByQueueNameAndConsumerTypeCode(rabbitMqPlusConsumerTaskPO);
        return false;
    }

    @Override
    public List<RabbitMqPlusConsumerTaskDTO> queryTodoDataByStatus(List<Integer> status) {
        List<RabbitMqPlusConsumerTaskPO> data = rabbitMqPlusConsumerTaskRepository.queryTodoDataByStatus(status);
        return ObjectUtils.copyListProperties(data, RabbitMqPlusConsumerTaskDTO.class);
    }

    @Override
    public boolean deleteInvalidDataByDay(int day) {
        return rabbitMqPlusConsumerTaskRepository.deleteInvalidDataByDay(day);
    }

}
